/**
 * @description 路由配置文件
*/

// const router = {
//   routes: [
//     {
//       path: '/ox/demo', // 示例
//       controller: DemoController,
//       children: [
//         {
//           path: 'list', // 示例列表
//           method: 'get',
//           action: 'queryAll'
//         }
//       ]
//     }
//   ]
// }
/* 自定义控制器 */
// 仅本地增、删、改
let permission = {
  // hosts: 'localhost',
  rules: ['admin']
}

const router = {
  routes: [
    {
      path: '/dpad/nave', // 导航
      controller: require('../modules/nave/controller.js'),
      children: [
        {
          path: 'list/page',
          method: 'get',
          action: 'queryAll',
          excute: {
            operators: [
              {field: 'id', operator: 'EQUAL'},
              {field: 'name', operator: 'LIKE'},
              {field: 'href', operator: 'LIKE'},
              {field: 'createTime', operator: 'BETWEEN'},
              {field: 'updateTime', operator: 'BETWEEN'}
            ],
            sort: [
              {field: 'order', by: 'desc'}
            ]
          },
          isCheckToken: false
        },
        {
          path: 'item',
          method: 'get',
          action: 'query',
          isCheckToken: false
        },
        {
          path: 'item',
          method: 'put',
          action: 'add',
          permission: permission
        },
        {
          path: 'item',
          method: 'post',
          action: 'update',
          permission: permission
        },
        {
          path: 'item',
          method: 'delete',
          action: 'deleteAll',
          permission: permission
        },
        {
          path: 'list/treeall',
          method: 'get',
          action: 'queryTreeSub',
          excute: {
            sort: [
              {field: 'order', by: 'desc'}
            ],
            treeLevel: 18
          },
          isCheckToken: false
        },
        {
          path: 'list/tree',
          method: 'get',
          action: 'queryTreeSub',
          excute: {
            sort: [
              {field: 'order', by: 'desc'}
            ],
            treeLevel: 3
          },
          isCheckToken: false
        }
      ]
    },
    {
      path: '/dpad/note', // 笔记
      controller: require('../modules/note/controller.js'),
      children: [
        {
          path: 'list/page',
          method: 'get',
          action: 'queryAllByPage',
          excute: {
            operators: [
              {field: 'title', operator: 'LIKE'},
              {field: 'type', operator: 'EQUAL'},
              {field: 'labels', operator: 'LIKE'},
              {field: 'content', operator: 'LIKE'},
              {field: 'createTime', operator: 'BETWEEN'},
              {field: 'updateTime', operator: 'BETWEEN'}
            ],
            fields: [
              {field: 'id'},
              {field: 'title'},
              {field: 'labels'},
              {field: 'order'},
              {field: 'storeExpire'},
              {field: 'type'},
              {field: 'createTime'},
              {field: 'updateTime'}
            ],
            limit: {
              pageSize: {field: 'pageSize', default: 10},
              pageIndex: {field: 'pageIndex', default: 1}
            }
          },
          isCheckToken: false
        },
        {
          path: 'list/options',
          method: 'get',
          action: 'queryAll',
          excute: {
            fields: [
              {field: 'id'},
              {field: 'title'}
            ],
            operators: [
              {field: 'title', operator: 'LIKE'},
              {field: 'type', operator: 'EQUAL'},
              {field: 'labels', operator: 'LIKE'},
              {field: 'content', operator: 'LIKE'},
              {field: 'createTime', operator: 'BETWEEN'},
              {field: 'updateTime', operator: 'BETWEEN'}
            ],
            sort: [
              {field: 'createTime', by: 'desc'},
              {field: 'order', by: 'desc'}
            ]
          },
          isCheckToken: false
        },
        {
          path: 'item',
          method: 'get',
          action: 'query',
          isCheckToken: false
        },
        {
          path: 'item',
          method: 'put',
          action: 'add',
          permission: permission
        },
        {
          path: 'item',
          method: 'post',
          action: 'update',
          permission: permission
        },
        {
          path: 'item',
          method: 'delete',
          action: 'deleteAll',
          permission: permission
        }
      ]
    },
    {
      path: '/dpad/noteType', // 笔记类型
      controllerName: 'noteType',
      tableName: 'note-type',
      children: [
        {
          path: 'list',
          method: 'get',
          action: 'queryAll',
          excute: {
            sort: [
              {field: 'createTime', by: 'desc'},
              {field: 'order', by: 'desc'}
            ]
          },
          isCheckToken: false
        },
        {
          path: 'item',
          method: 'get',
          action: 'query',
          isCheckToken: false
        },
        {
          path: 'item',
          method: 'put',
          action: 'add',
          permission: permission
        },
        {
          path: 'item',
          method: 'post',
          action: 'update',
          permission: permission
        },
        {
          path: 'item',
          method: 'delete',
          action: 'delete',
          permission: permission
        }
      ]
    },
    {
      path: '/dpad/doc', // 文档
      controller: require('../modules/docer/controller.js'),
      children: [
        {
          path: 'list/page',
          method: 'get',
          action: 'queryAllByPage',
          excute: {
            fields: [],
            operators: [
              {field: 'pid', operator: 'EQUAL'},
              {field: 'name', operator: 'LIKE'},
              {field: 'ext', operator: 'LIKE'},
              {field: 'size', operator: 'BETWEEN'},
              {field: 'data', operator: 'CUSTOM'},
              {field: 'createTime', operator: 'BETWEEN'},
              {field: 'updateTime', operator: 'BETWEEN'}
            ],
            limit: {
              pageSize: {field: 'pageSize', default: 10},
              pageIndex: {field: 'pageIndex', default: 1}
            }
          }
        },
        {
          path: 'item',
          method: 'get',
          action: 'query'
        },
        {
          path: 'item',
          method: 'put',
          action: 'add',
          permission: permission
        },
        {
          path: 'item',
          method: 'post',
          action: 'update',
          permission: permission
        },
        {
          path: 'item',
          method: 'delete',
          action: 'deleteAll',
          permission: permission
        },
        {
          path: 'list/tree',
          method: 'get',
          action: 'queryTreeSup'
        },
        {
          path: 'file/path',
          method: 'get',
          action: 'openFileDir',
          permission: permission
        },
        {
          path: 'file/app/download',
          method: 'get',
          action: 'downloadFile'
        },
        {
          path: 'file/read',
          method: 'get',
          action: 'readFile',
          permission: permission
        },
        {
          path: 'file/update',
          method: 'post',
          action: 'updateName'
        }
      ]
    },
    {
      path: '/dpad/direct', // 目录
      controller: require('../modules/direct/controller.js'),
      children: [
        {
          path: 'list/tree',
          method: 'get',
          action: 'queryTreeSub',
          excute: {
            operators: [
              {field: 'id', operator: 'EQUAL'},
              {field: 'pid', operator: 'EQUAL'},
              {field: 'name', operator: 'LIKE'},
              {field: 'createTime', operator: 'BETWEEN'},
              {field: 'updateTime', operator: 'BETWEEN'}
            ],
            sort: [
              {field: 'order', by: 'desc'}
            ]
          }
        },
        {
          path: 'item',
          method: 'get',
          action: 'query'
        },
        {
          path: 'item',
          method: 'put',
          action: 'add',
          permission: permission
        },
        {
          path: 'item',
          method: 'post',
          action: 'update',
          permission: permission
        },
        {
          path: 'item',
          method: 'delete',
          action: 'deleteAll',
          permission: permission
        }
      ]
    },
    {
      path: '/dpad/task', // 任务
      controller: require('../modules/task/controller.js'),
      children: [
        {
          path: 'list/page',
          method: 'get',
          action: 'queryAllByPage',
          excute: {
            fields: [],
            operators: [
              {field: 'name', operator: 'LIKE'},
              {field: 'type', operator: 'IN'},
              {field: 'status', operator: 'IN'},
              {field: 'description', operator: 'LIKE'},
              {field: 'createTime', operator: 'BETWEEN'},
              {field: 'updateTime', operator: 'BETWEEN'}
            ],
            sort: [
              {field: 'order', by: 'desc'}
            ]
          }
        },
        {
          path: 'item',
          method: 'get',
          action: 'query'
        },
        {
          path: 'item',
          method: 'put',
          action: 'add',
          permission: permission
        },
        {
          path: 'item',
          method: 'post',
          action: 'update',
          permission: permission
        },
        {
          path: 'item',
          method: 'delete',
          action: 'deleteAll',
          permission: permission
        },
        {
          path: 'list/tree',
          method: 'get',
          action: 'queryTreeSub',
          excute: {
            sort: [
              {field: 'order', by: 'desc'}
            ]
          }
        }
      ]
    },
    {
      path: '/dpad/taskType', // 任务类型
      controllerName: 'taskType',
      tableName: 'task-type',
      children: [
        {
          path: 'list',
          method: 'get',
          action: 'queryAll',
          excute: {
            sort: [
              {field: 'createTime', by: 'desc'},
              {field: 'order', by: 'desc'}
            ]
          }
        },
        {
          path: 'item',
          method: 'get',
          action: 'query'
        },
        {
          path: 'item',
          method: 'put',
          action: 'add',
          permission: permission
        },
        {
          path: 'item',
          method: 'post',
          action: 'update',
          permission: permission
        },
        {
          path: 'item',
          method: 'delete',
          action: 'delete',
          permission: permission
        }
      ]
    },
    {
      path: '/dpad/dictionary', // 字典
      controllerName: 'dictionary',
      tableName: 'dictionary',
      children: [
        {
          path: 'list',
          method: 'get',
          action: 'queryAll',
          excute: {
            operators: [
              {field: 'cat', operator: 'EQUAL'},
              {field: 'code', operator: 'LIKE'},
              {field: 'key', operator: 'LIKE'},
              {field: 'value', operator: 'LIKE'},
              {field: 'description', operator: 'LIKE'},
              {field: 'remark', operator: 'LIKE'},
            ],
            sort: [
              {field: 'id', by: 'desc'},
              {field: 'cat', by: 'desc'},
              {field: 'code', by: 'desc'},
              {field: 'key', by: 'desc'},
              {field: 'value', by: 'desc'},
              {field: 'description', by: 'desc'},
              {field: 'remark', by: 'desc'},
              {field: 'dimension', by: 'desc'},
              {field: 'updateTime', by: 'desc'},
              {field: 'updateUser', by: 'desc'},
              {field: 'createTime', by: 'desc'},
              {field: 'createUser', by: 'desc'},
              {field: 'order', by: 'desc'}
            ]
          },
          isCheckToken: false
        },
        {
          path: 'item',
          method: 'get',
          action: 'query',
          excute: {
            sort: [
              {field: 'id', by: 'desc'},
              {field: 'cat', by: 'desc'},
              {field: 'code', by: 'desc'},
              {field: 'key', by: 'desc'},
              {field: 'value', by: 'desc'},
              {field: 'description', by: 'desc'},
              {field: 'remark', by: 'desc'},
              {field: 'order', by: 'desc'},
              {field: 'dimension', by: 'desc'},
              {field: 'updateTime', by: 'desc'},
              {field: 'updateUser', by: 'desc'},
              {field: 'createTime', by: 'desc'},
              {field: 'createUser', by: 'desc'}
            ]
          },
          isCheckToken: false
        },
        {
          path: 'item',
          method: 'put',
          action: 'add',
          permission: permission
        },
        {
          path: 'item',
          method: 'post',
          action: 'update',
          excute: {
            sort: [
              {field: 'id', by: 'desc'}
            ]
          },
          permission: permission
        },
        {
          path: 'item',
          method: 'delete',
          action: 'delete',
          excute: {
            sort: [
              {field: 'id', by: 'desc'}
            ]
          },
          permission: permission
        },
        {
          path: 'list/tree',
          method: 'get',
          action: 'queryTreeSub',
          excute: {
            sort: [
              {field: 'order', by: 'desc'}
            ],
            treeLevel: 3
          }
        }
      ]
    },
    {
      path: '/dpad/data', // 数据
      controllerName: 'data',
      tableName: 'data',
      children: [
        {
          path: 'list/all',
          method: 'get',
          action: 'queryAll',
          excute: {
            fields: [],
            operators: [
              {field: 'id', operator: 'EQUAL'},
              {field: 'did', operator: 'EQUAL'},
              {field: 'name', operator: 'LIKE'},
              {field: 'href', operator: 'LIKE'},
              {field: 'data', operator: 'LIKE'},
              {field: 'createTime', operator: 'BETWEEN'},
              {field: 'updateTime', operator: 'BETWEEN'}
            ]
          }
        },
        {
          path: 'list/page',
          method: 'get',
          action: 'queryAllByPage',
          excute: {
            fields: [],
            operators: [
              {field: 'id', operator: 'EQUAL'},
              {field: 'did', operator: 'EQUAL'},
              {field: 'name', operator: 'LIKE'},
              {field: 'href', operator: 'LIKE'},
              {field: 'data', operator: 'LIKE'},
              {field: 'createTime', operator: 'BETWEEN'},
              {field: 'updateTime', operator: 'BETWEEN'}
            ]
          }
        },
        {
          path: 'item',
          method: 'get',
          action: 'query'
        },
        {
          path: 'item',
          method: 'put',
          action: 'add',
          permission: permission
        },
        {
          path: 'item',
          method: 'post',
          action: 'update',
          permission: permission
        },
        {
          path: 'item',
          method: 'delete',
          action: 'deleteAll',
          permission: permission
        }
      ]
    },
    {
      path: '/dpad/user', // 用户页面
      controllerName: 'user',
      children: [
        {
          path: 'login',
          method: 'post',
          action: 'login'
        },
        {
          path: 'logout',
          method: 'post',
          action: 'logout'
        },
        {
          path: 'queryUserInfo',
          method: 'get',
          action: 'queryUserInfo'
        }
      ]
    }
  ]
}

module.exports = router